package com.mj.common.sdk.api;

import com.mj.common.config.AppConfig;
import com.mj.common.sdk.beans.message.MessageTemplate;
import com.mj.common.sdk.tools.HttpUtil;
import com.mj.common.util.JSONUtil;

/**
 * 模版发送客户端
 * 
 * @author zhouping
 *
 */
public class MessageTemplateClient extends AbstractClient {

	//发送数据
	public ApiResult sendMessage(String jsonStr) {
		AccessToken accessToken = getAccessToken();
		String jsonResult = HttpUtil.post(AppConfig.WEI_XIN_TEMPLATE + accessToken.getAccessToken(), jsonStr);
		return proceResult(jsonResult);
	}
	
	/**
     * 构建发送数据
     */
    public ApiResult createMessage(MessageTemplate messageTemplate) {
        String jsonStr = JSONUtil.toJson(messageTemplate);
        return sendMessage(jsonStr);
    }
}
